<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script>
	$(function(){
		$.ajax({
			type:"post",
			url:"${initParam.root}searchWordRank.do",
			success:function(jsonData){
				//alert(jsonData.length);
				var tbody="";
				$.each(jsonData,function(index,value){
					tbody+="<tr>";
					tbody+="<td align=center>"+value.RANK+"</td>";
					tbody+="<td align=center><a href='${initParam.root}mypage/totalSearch.do?word="+value.SEARCH_WORD+"'>"+value.SEARCH_WORD+"</a></td>";
					tbody+="</tr>";
				});
				$("#searchWordRankResultView").html(tbody);
			}
		}); // ajax
		/* self.setInterval(function(){
			$.ajax({
				type:"post",
				url:"${initParam.root}loginMemberRank.do",
				success:function(jsonData){
					//alert(jsonData.length);
					var tbody="";
					$.each(jsonData,function(index,value){
						tbody+="<tr>";
						tbody+="<td>"+value.RANK+"</td>";
						tbody+="<td>"+value.M_ID+"</td>";
						tbody+="</tr>";
					});
					$("#rankResultView").html(tbody);
				}
			}); // ajax
		}, 10000); // 10초에 한번 업데이트 */
		$.ajax({
			type:"post",
			url:"${initParam.root}loginMemberRank.do",
			success:function(jsonData){
				//alert(jsonData.length);
				var tbody="";
				$.each(jsonData,function(index,value){
					tbody+="<tr>";
					tbody+="<td align=center>"+value.RANK+"</td>";
					tbody+="<td align=center>"+value.M_ID+"</td>";
					tbody+="</tr>";
				});
				$("#loginMemberRankResultView").html(tbody);
			}
		}); // ajax
	});
</script>
<b>검색어 순위</b><br>
<table style="width:150px;">
	<thead>
		<tr>
			<th width="40%" align="center">순위</th>
			<th width="60%" align="center">검색어</th>
		</tr>
	</thead>
	<tbody id="searchWordRankResultView"></tbody>
</table>
<br>
<hr size="1" color="silver">
<br>
<b>회원 접속 순위</b><br>
<table style="width:150px;">
	<thead>
		<tr>
			<th width="40%" align="center">순위</th>
			<th width="60%" align="center">아이디</th>
		</tr>
	</thead>
	<tbody id="loginMemberRankResultView"></tbody>
</table>